home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5562 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  52 lines

  1. Path: geraldo.cc.utexas.edu!usenet
  2. From: wharris@mail.utexas.edu (W.  Harris)
  3. Newsgroups: comp.lang.c++
  4. Subject: problem writing class to a file.....  -  temp.txt [1/1]
  5. Date: 5 Feb 1996 16:10:22 GMT
  6. Organization: The University of Texas at Austin
  7. Message-ID: <4f5a5e$3ca@geraldo.cc.utexas.edu>
  8. NNTP-Posting-Host: slip-41-11.ots.utexas.edu
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain
  11. X-Newsreader: WinVN 0.90.4
  12.  
  13.  
  14.    The problem I'm having is in the code "outfile.write(char *)&.....".
  15.    The book I used to learn C, C++ indicates this should work.  The
  16.    compiler error I'm getting is "sizeof cannot be used on a 
  17.    function".  Code has been reduced; the struct definition and the 
  18.    constructor have been left out.  I've also opened the file for binary
  19.    output. (not indicated in code)
  20.    
  21.  
  22.    
  23.   class CarData
  24.     {
  25.     private :
  26.  
  27.     char VIN[7],Stock[7],Tag[7],Tech[4],Color[12],Model[16],Year[5];
  28.     char EstAmt[6],Name[35],Address[32],City[19],State[3],Zip[6];
  29.     char Area[4],Prefix[4],Num[5],WArea[4],WPrefix[4],WNum[5];
  30.     char FnlAmt[6];
  31.  
  32.     public :
  33.  
  34.     CarData(struct astruct1 CarInf);
  35.      };
  36.   //*********************************************************************
  37.  
  38.  
  39. void main()
  40.     {
  41.  
  42.        
  43.     CarData CarConst1(struct astruct1 CarInfo);   //1st instance of cnstctr
  44.     outfile.write((char *)&CarConst1, sizeof(CarConst1));  //*****ERROR IS OCCURRING HERE*
  45.     getch();
  46.     closegraph();
  47.     }
  48.  
  49.    //*******************************************************************
  50.  
  51.  
  52.